package com.jb.web.bean.list;

import com.jb.framework.PersistentContext;
import com.jb.web.bean.FloatPanel;
import com.jb.web.bean.Image;
import com.jb.web.bean.Label;
import com.jb.web.bean.TextField;


public class Paginator extends FloatPanel {
    static final long serialVersionUID = 123123L;
    static {
        publish(Paginator.class, GENERAL, "listId");
    }  
    
    private String listId;
    

    public void setDefault(PersistentContext pCtx) {
        // super.setDefault(pCtx);
        setStyleClass("jbWindow");
        Image img = new Image();
        img.setClientId(this.getClientId() + "first");
        img.setLocation("resources/images/grid/first.gif");
        img.setHoverImage("resources/images/grid/first_hover.gif");
        img.setDisableImage("resources/images/grid/first_disabled.gif");
        img.setDefaultValue("first");
        
        this.addFacet("first", img);
        img = new Image();
        img.setClientId(this.getClientId() + "prev");
        img.setLocation("resources/images/grid/prev.gif");
        img.setHoverImage("resources/images/grid/prev_hover.gif");
        img.setDisableImage("resources/images/grid/prev_disabled.gif");

        img.setDefaultValue("previous");
        img.setValue("Prev");
        this.addFacet("prev", img);

        Label l1 = new Label(); 
        this.addFacet("page", l1);
        l1.setValue("Page ");
        l1.setClientId(this.getClientId() + "page");

        TextField tf = new TextField();
        tf.setWidth("30px");
        tf.setFieldName("page");
        this.addFacet("pageField", tf);
        tf.setStyleClass("jb_list_page");
        tf.setClientId(this.getClientId() + "pageField");
        
        Label total = new Label(); 
        this.addFacet("total", total);
        total.setValue("of total ");
        total.setClientId(this.getClientId() + "total");

        img = new Image();
        img.setClientId(this.getClientId() + "next");
        img.setLocation("resources/images/grid/next.gif");
        img.setHoverImage("resources/images/grid/next_hover.gif");
        img.setDisableImage("resources/images/grid/next_disabled.gif");
        img.setDefaultValue("next");
        
        img.setValue("Next");
        this.addFacet("next", img);

        img = new Image();
        img.setClientId(this.getClientId() + "last");
        img.setLocation("resources/images/grid/last.gif");
        img.setHoverImage("resources/images/grid/last_hover.gif");
        img.setDisableImage("resources/images/grid/last_disabled.gif");
        img.setDefaultValue("last");
        img.setValue("Last");
        this.addFacet("last", img);
    }

    public void setListId(String param) {
        this.listId = param;
    }

    public String getListId() {
        return listId;
    }
}
